function[correct_count] = perceptronValidation(p_trainingSet, p_testSet, display,modus)

  if (display >0)
    disp('PERCEPTRON CLASSIFICATION');
  end
   % strokes = loadStrokes(modus);
%     if modus == 1
%         strokes(1,:) = strokes(1,:) - 1;
%     end
    F = dir('FeatureCombinationDefs/*.txt');
    correct_count = zeros(1,size(F, 1));
    for featureFilter = 1 : size(F, 1)
        %featureFilteredStrokes = filterFeatures(strokes, ['FeatureCombinationDefs/' F(featureFilter).name]);
        featureFilteredTrainingSet = filterFeatures(p_trainingSet, ['FeatureCombinationDefs/' F(featureFilter).name]);
        featureFilteredTestSet = filterFeatures(p_testSet, ['FeatureCombinationDefs/' F(featureFilter).name]);

        if (display >0)
            disp(['Feature combination according to file [' F(featureFilter).name ']']);
        end
        %D = dir('TrainingSetDefs/*.txt');
        %for split = 1 : size(D, 1)
            %[trainingSet, testSet] = splitIntoTrainingAndTest(featureFilteredStrokes, ['TrainingSetDefs/' D(split).name]);
            trainingSet = featureFilteredTrainingSet;
            testSet = featureFilteredTestSet;
            correct = 0;
            if modus == 1
                % loadStrokes returns class IDs 1 and 2, but perco requires 0 and 1
                trainingSet(1,:) = trainingSet(1,:) - 1;
                testSet(1,:) = testSet(1,:) - 1;
                weights = perco(trainingSet(2:end,:), trainingSet(1,:), 100);
            else
                weights = percoMultiClass(trainingSet(2:end,:), trainingSet(1,:), 100);
            end
            converged = isempty(find(weights(end,:) == false, 1));
            for i = 1 : size(testSet, 2)
                if (modus == 1)
                    result = perceptronClassification(testSet(2:end, i), weights(1:end-1));
                else
                    result = perceptronMultiClassification(testSet(2:end, i), weights(1:end-1,:));
                end
                if result == testSet(1, i)
                    correct = correct + 1;
                end
            end
            suffix = '';
            if ~converged
                suffix = '  (did not converge)';
            end
            
            correct_count(1,featureFilter)=correct;
            
            %disp(['  Training/Test separation [' D(split).name ']: ' num2str(correct) '/' num2str(size(testSet, 2)) ' -> ' num2str(correct/size(testSet, 2)*100) '%' suffix]);
        %end
    end
end
